#include <bits/stdc++.h>
using namespace std;

set<int> mp[10];
int a[10][10];
int main()
{
	// freopen("lock.in", "r", stdin);
	// freopen("lock.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, i, j;
	cin >> n;
	if (n == 1)
	{
		cout << "81\n";
	}
	else // spacial A
	{
		for (i = 1; i <= n; ++i)
		{
			for (j = 1; j <= 5; ++j)
			{
				cin >> a[i][j];
				mp[j].insert(a[i][j]);
			}
		}
		int ans = 0;
		for (i = 1; i <= 5; ++i)
		{
			ans += 10 - mp[i].size();
		}
		cout << ans << '\n';
		/*
		8
		2 0 0 0 0
		0 2 0 0 0
		0 0 0 0 0
		1 0 0 0 0
		0 0 1 0 0
		0 1 0 0 0
		0 0 0 1 0
		0 0 0 2 0
		*/
	}
	return 0;
}
